image
behavior在Hashicorp forum看到這篇文章很有趣 Nomadproject.io missing documentation about Docker driver image
behavior。
有使用者發現Nomad文件並未對nomad pull image,是先檢查本地還是先從docker hub拉取有說明,所以看能不能在文件上說明,然後找出code, 說明Nomad在 image tag 是有特別處理的,後來Nomad文件也補上說明。
. image - The Docker image to run. The image may include a tag or custom URL and should include https:// if required. By default it will be fetched from Docker Hub. If the tag is omitted or equal to latest the driver will always try to pull the image.
If the image to be pulled exists in a registry that requires authentication credentials must be provided to Nomad. Please see the Authentication section.
// loading it from the file system
func (d *Driver) createImage(task *drivers.TaskConfig, driverConfig *TaskConfig, client *docker.Client) (string, error) {
image := driverConfig.Image
repo, tag := parseDockerImage(image)
// We're going to check whether the image is already downloaded. If the tag
// is "latest", or ForcePull is set, we have to check for a new version every time so we don't
// bother to check and cache the id here. We'll download first, then cache.
if driverConfig.ForcePull {
d.logger.Debug("force pulling image instead of inspecting local", "image_ref", dockerImageRef(repo, tag))
} else if tag != "latest" {
if dockerImage, _ := client.InspectImage(image); dockerImage != nil {
// Image exists so just increment its reference count
d.coordinator.IncrementImageReference(dockerImage.ID, image, task.ID)
return dockerImage.ID, nil
}
}
// Load the image if specified
if driverConfig.LoadImage != "" {
return d.loadImage(task, driverConfig, client)